functions - synonyms routine process sub-routine sub method goals reduce complexity remove redundent code (one place to fix a problem) document code "Say it in code" 2 categorys functions that give an answer - non-void functions functions that just do their job - void functions parameters - the varibles in the () of a function, they should dictate what the function does the parameters alreay have values, in is not required to ask the user for values within the function void - the function does not return a answer a function that returns a value can be treated a constant variable nameing funcitons void - verb or verb noun combination print, print document, displaySum non-void - noun or adjective-noun sum, currentBalance, todaysDate name as you would a varible, describe the data parameter argument Homework write 2 functions one that returns the factorial of an integer one that displays the factorial of an integer In main show that the funcitons work by calling them Get a number from the user to pass to the functions ///////////////////////////////////////////////////////////// #include #include using namespace std; void displayTime() { cout << "Time" << endl; } void dispayPower(int x, int y) { int answer = 1; while(y > 0) { answer = answer * x; y--; } cout << answer << endl; } int power(int x, int y) { int answer = 1; while(y > 0) { answer = answer * x; y--; } return answer; } int absoluteValue( int number ) { int result = number; if(result < 0) { result *= -1; } return result; } void displayAbsoluteValue(int number) { cout << absoluteValue(number) << endl; } void main() { dispayPower(7,3); int p = power(7,3); //power(5,9) = 2; this is wrong cout << "the value that was returned is " << p << endl; int x; cin >> x; cout << absoluteValue(x) << endl; //cout << "Start" << endl; //displayTime(); //cout << "Stop" << endl; }